<?php
/**
 * ログインモデルクラス<br />
 *
 * @package apamanshop
 * @author Y.Shibutani
 * @copyright
 */
class Mypage_Model_Login extends Apm_Model_Base
{
	/**
	 * アカウント情報の取得
	 *
	 * @param String $id ID
	 * @param String $password パスワード
	 * @return エラーコード
	 */
	public function getAccount($id,$password)
	{
		//DBパラメータ用配列生成
    	$db_params = array();

    	//=====パラメータ設定=====
        $db_params['eID'] = $id;
    	$db_params['ePass'] = $password;

        //=====SQL生成=====
		$strSQL  = "SELECT M92_USER_CD, M92_HANDLE_NAME FROM M92MYPAGE_USER ";
		$strSQL .= "WHERE M92_E_MAIL = :eID ";
		$strSQL .= "AND M92_PASSWORD = :ePass ";
		$strSQL .= "AND M92_DELETE_FLG = '0' ";

		//=====データ取得=====
		$userList = $this->dbGetList($strSQL, $db_params);
		return $userList;
	}

	public function InsertLog($ucd,$db)
	{
		$sql = "INSERT INTO W21PAGE_VIEW_LOG_MYPAGE ";
		$sql .= "(W21_DATE,W21_USER_ID) VALUES (SYSDATE, :ucd)";

		$db_params = array();
		$db_params['ucd'] = $ucd;
		$this->dbExecQuery($sql,$db_params,$db);
	}

	public function loginDate($ucd,$db)
	{
		$sql = "UPDATE M92MYPAGE_USER SET ";
		$sql .= "M92_PC_LAST_LOGIN_YMD = SYSDATE";
		$sql .= ",M92_PC_LOGIN_CNT = M92_PC_LOGIN_CNT + 1 ";
		$sql .= "WHERE ";
		$sql .= "M92_USER_CD = :ucd";

		$db_params = array();
		$db_params['ucd'] = $ucd;

		$this->dbExecQuery($sql,$db_params,$db);
	}
}
?>